package com.zlsy.thread.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 * @author zhouliang
 * @date 2020/7/4 13:50
 */
public class IsTerminatedThreadPool {

    public static void main(String[] args) throws InterruptedException {
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        for (int i = 0; i < 10; i++) {
            executorService.execute(() -> {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName());
            });
        }

        executorService.shutdown();

        TimeUnit.SECONDS.sleep(5);

        boolean terminated = executorService.isTerminated();

        System.out.println("线程池是否已经完全停止：" + terminated);

    }
}
